import os
import sys

def savefile(file_name, file_datas):
    with open(file_name, mode='wb+') as file:
        file.write(file_datas)


def pinjie(path, *paths):
    os.path.join(path, *paths)

def get_file_list(folder_path):
    """
    获取文件列表
    :param folder_path:
    :return:
    """
    return os.listdir(folder_path)

def get_project_path(filepath=__file__):
    """
    获取项目路径
    :param filepath: 文件的路径，默认为当前文件(__file__)
    :return: 项目路径
    """
    # print(os.path.abspath(filepath))  # 调试用，生产环境可注释或删除
    return os.path.abspath(os.path.dirname(filepath))

def get_project_path(filepath=__file__):
    """
    获取项目路径
    :param filepath: default=__file__
    :return:
    """
    print(os.path.abspath(filepath))
    return os.path.abspath(os.path.dirname(filepath))


def add_package_path_to_sys_path(package_path):
    sys.path.append(package_path)


def check_file_exist(filename):
    return os.path.exists(filename)


def check_path_exist(pathname):
    return os.path.exists(pathname)


def make_dir(path):
    """
    make dir
    :param path:
    :return:
    """
    if not os.path.exists(path):
        os.makedirs(path)


if __name__ == '__main__':
    print(sys.path)
    print(os.path)
    print(__file__)
    get_project_path()

